package com.cskaoyan.javase.oop3._2inner._2static._1use;

/**
 * 静态内部类和外围类之间的访问和普通类没有区别,互相new对象就可以访问了.
 * 唯一的区别是,互相访问不受权限限制.
 *
 * 在外部类中访问静态内部类:
 *      首先访问的全程都受权限限制
 *      其次不需要创建外围类对象,可以直接创建静态内部类对象
 *      语法:
 *      EnclosedClazz.NestedClazz nc = new EnclosedClazz.NestedClazz();
 *
 *
 * @since 11:28
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    public static void main(String[] args) {
        EnclosedClazz.NestedClazz nc = new EnclosedClazz.NestedClazz();
        System.out.println(nc.a);
        // nc.b
    }
}

class EnclosedClazz {
    int a;
    private int b = 10;
    static int c = 20;
    static final int D = 30;

    public void test(){
        NestedClazz nc = new NestedClazz();
        System.out.println(nc.a);
        System.out.println(nc.b);
    }
    public static void testStatic(){
        NestedClazz nc = new NestedClazz();
        System.out.println(nc.a);
        System.out.println(nc.b);
    }


     static class NestedClazz {
        int a;
        private int b = 10;
        static int c = 20;
        static final int D = 30;

        public void testNested() {
            EnclosedClazz ec = new EnclosedClazz();
            System.out.println(ec.a);
            System.out.println(ec.b);
            System.out.println(a);
            System.out.println(b);
        }

        public static void testStaticNested() {
            EnclosedClazz ec = new EnclosedClazz();
            System.out.println(ec.a);
            System.out.println(ec.b);
            NestedClazz nc = new NestedClazz();
            System.out.println(nc.a);
            System.out.println(nc.b);
        }
    }
}